package dialogs;

import java.awt.event.ActionEvent;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import controllers.AbstractController;
import controllers.TopSellingItemsController;

public class TopSellingItemsDialog extends AbstractGeneralPurposeDialog {

	TopSellingItemsController controller;
	public TopSellingItemsDialog(JFrame parent, AbstractController c) {
		super(parent, "Top Selling Items", "Top Selling Items", new String[] {"Date", "Number of Top Selling Items"}, c);
		controller = (TopSellingItemsController) c;		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("OK"))
		{
			int retCode = controller.validateEntries(text_fields.get(0).getText().trim(), text_fields.get(1).getText().trim());
			if(retCode == VALIDATIONERROR)
				JOptionPane.showMessageDialog(this, "Please fill in all of the fields", "Error",
						JOptionPane.ERROR_MESSAGE);
			else if(retCode == OPERATIONFAILED)
				JOptionPane.showMessageDialog(this, "Unable to generate daily sales report", "Error",
						JOptionPane.ERROR_MESSAGE);
			else 
				dispose();
		}
	}

}
